//
//  DefaultMLRefreshControlAnimateView.m
//  TycoonSale
//
//  Created by molon on 15/8/18.
//  Copyright (c) 2015年 molon. All rights reserved.
//

#import "DefaultMLRefreshControlAnimateView.h"

@interface DefaultMLRefreshControlAnimateView()

@property (nonatomic,strong) UILabel *textLabel;

@end

@implementation DefaultMLRefreshControlAnimateView


#pragma mark - layout
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.textLabel.frame = self.bounds; //默认撑满全部
    
}

#pragma mark - getter setter
- (UILabel*)textLabel
{
    if (!_textLabel) {
        _textLabel = [[UILabel alloc]init];
        _textLabel.font = [UIFont boldSystemFontOfSize:13];
        _textLabel.textColor = [UIColor grayColor];
        _textLabel.backgroundColor = [UIColor clearColor];
        _textLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_textLabel];
    }
    return _textLabel;
}


- (void)setState:(MLRefreshControlState)state
{
    [super setState:state];
    
    //检测当前状态是什么
    switch (state) {
        case MLRefreshControlStateNormal:
            self.textLabel.text = @"下拉可刷新";
            break;
        case MLRefreshControlStatePulling:
            self.textLabel.text = @"下拉刷新";
            break;
        case MLRefreshControlStateOverstep:
            self.textLabel.text = @"松开刷新数据";
            break;
        case MLRefreshControlStateRefreshing:
            self.textLabel.text = @"正在载入...";
            break;
        default:
            break;
    }
}

- (void)setPullingProgress:(float)pullingProgress
{
    [super setPullingProgress:pullingProgress];
    
    if (self.state != MLRefreshControlStatePulling) {
        return;
    }
//        NSUInteger dotCount = (NSUInteger)(pullingProgress*100)/20;
//        NSString *text = @"下拉刷新";
//        for (NSUInteger i=0; i<dotCount; i++) {
//            text = [text stringByAppendingString:@"."];
//        }
//        self.textLabel.text = text;
    
    self.textLabel.text = @"下拉刷新";
    
//    self.textLabel.text = [NSString stringWithFormat:@"下拉刷新%ld%%",(NSInteger)(pullingProgress*100)];
}


@end
